/*
 * Copyright (C), 2015-2018
 * FileName: TouchController
 * Author:   zhao
 * Date:     2019/1/8 16:17
 * Description: 触摸游戏
 * History:
 * <author>          <time>          <version>          <desc>
 * 作者姓名           修改时间           版本号              描述
 */
package com.lizhaoblog.game.sbs.tmptouch.controller;

import com.lizhaoblog.game.sbs.tmptouch.base.message.JsonRep;
import com.lizhaoblog.game.sbs.tmptouch.entity.GeUser;
import com.lizhaoblog.game.sbs.tmptouch.service.GeUserService;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

/**
 * 〈一句话功能简述〉<br>
 * 〈触摸游戏〉
 *
 * @author zhao
 * @date 2019/1/8 16:17
 * @since 1.0.1
 */
@RestController
@RequestMapping("/touch")
public class TouchController {
    @Autowired
    private GeUserService geUserService;

    /**
     * 查看所有列表
     */
    @RequestMapping("/all")
    public JsonRep queryAll(@RequestParam Map<String, Object> params) {
        List<GeUser> list = geUserService.listByParam(params);
        return JsonRep.success().put("list", list);
    }

    /**
     * 查看列表
     */
    @RequestMapping("/list")
    public JsonRep list(@RequestParam Map<String, Object> params) {
        //        //查询列表数据
        //        Query query = new Query(params);
        //        List<GeUser> geUserList = geUserService.listByParam(query);
        //        int total = geUserService.count().intValue();
        //
        //        PageUtils pageUtil = new PageUtils(geUserList, total, query.getLimit(), query.getPage());
        //        return JsonRep.success().put("page", pageUtil);
        return null;
    }

    /**
     * 查看信息
     */
    @RequestMapping("/info/{uid}")
    public JsonRep info(@PathVariable("uid") Integer uid) {
        GeUser geUser = geUserService.findOne(uid);
        return JsonRep.success().put("geUser", geUser);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    public JsonRep save(@RequestBody GeUser geUser) {
        System.out.println(geUser);
        geUserService.save(geUser);
        return JsonRep.success();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    public JsonRep update(@RequestBody GeUser geUser) {
        geUserService.update(geUser);
        return JsonRep.success();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    public JsonRep delete(@RequestBody Integer[] uids) {
        geUserService.deleteByIdArray(uids);
        return JsonRep.success();
    }
}
